
public class StudentBiz {
	String[] names = new String[30];

	public void addName(String name){
		for (int i = 0; i < names.length; i++) {
			if(names[i]==null){
				names[i] = name;
				break;
			}
		}
	}

	public boolean delName(String name){
		int index = searchName(name);
		
		if(index!=-1){
			int i;
			for (i = index; i < names.length-1&&names[i]!=null; i++) {
				names[i] = names[i+1];
			}
			names[i] = null;
			
			return true;
		}

		return false;
	}

	public void showName(){
		for (int i = 0; i < names.length; i++) {
			if(names[i]!=null){
				System.out.print(names[i]+" ");
			}
		}
		System.out.println();
	}

	public int searchName(String name){
		for (int i = 0; i < names.length; i++) {
			if(names[i]!=null&&names[i].equals(name)){
				return i;
			}
		}

		return -1;
	}

	public boolean modifyName(String oldName,String newName){
		int index = searchName(oldName);

		if(index!=-1){
			names[index] = newName;
			return true;
		}

		return false;
	}

	public static void main(String[] args) {
		StudentBiz sb1 = new StudentBiz();
		sb1.addName("zhangsan");
		sb1.addName("lisi");
		sb1.addName("wangwu");
		sb1.addName("zhaoliu");
		sb1.showName();

		sb1.delName("zhangsan");
		sb1.delName("zhaoliu");
		sb1.delName("lisi");
		sb1.delName("wangwu");
		sb1.showName();
	}
}

